<?php
    use yii\helpers\Html;
    use yii\bootstrap\Nav;
    use yii\bootstrap\NavBar;
    use yii\widgets\Breadcrumbs;
    use app\assets\AppAsset;
    use yii\helpers\Url;
    use yii\web\View;

    AppAsset::register($this);
    $this->registerJsFile("@web/js/vendor/modernizr-2.8.3.min.js", ['position' => View::POS_HEAD]);
    $switchUrl = Url::to(['home/advertiser-switch']);
    $sysDefaultUrl = Url::to(['home/index']);
    $this->registerJs("VAM.setVar('ADVERTISER_SWITCH_URL', '$switchUrl')", View::POS_HEAD);
    $this->registerJs("VAM.setVar('SYS_DEFAULT_URL','$sysDefaultUrl');", View::POS_HEAD);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="../../favicon.ico">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
<!-- [if lt IE 9]>
  <script src="<?= Yii::getAlias('@web').'/js/vendor/html5.js'?>"></script>
  <script src="<?= Yii::getAlias('@web').'/js/vendor/excanvas.min.js'?>"></script>
  <script src="<?= Yii::getAlias('@web').'/js/vendor/respond.min.js'?>"></script>
<![endif] -->
</head>
<body>

<?php $this->beginBody() ?>
<!--[if lt IE 7]>
  <p class="alert alert-info">
      You are using an <strong>outdated</strong>
      browser. 
      Please <a href="http://browsehappy.com/" class="alert-link">upgrade your browser</a> to improve your experience.
  </p>
<![endif]-->
  <div class="wrap">
    <input type="hidden" id="current-header" value="<?= Yii::$app->controller->currentHeader; ?>"> 
    <input type="hidden" id="current-navigator" value="<?= Yii::$app->controller->currentNav; ?>"> 
    <header class="header-wrap clearfix" id="header-wrap">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#header-nav-wrap">
          <span class="sr-only">Toggle navigation</span>
          <i class="fa fa-bars fa-2x"></i>
        </button>
        <!-- <button type="button" class="navbar-toggle pull-left" data-toggle="collapse" data-target="#header-nav-wrap">
          <span class="sr-only">Toggle navigation</span>
          <i class="fa fa-bars fa-lg"></i>
        </button> -->
        <a class="navbar-brand" href="<?php echo Url::to(['home/index']); ?>" title="ValueMaker DSP">
          <img src="<?php echo Yii::getAlias('@web');?>/img/new-logo.png" alt="ValueMaker DSP" class="img-rounded">
        </a>
      </div>
      <nav class="collapse navbar-collapse headerbar" role="navigation" id="header-nav-wrap">
        <ul class="nav navbar-nav header-navbar">
          <li class="" id="header-site">
            <a href="<?php echo Url::to(['home/index']); ?>">
              <i class="fa fa-dashboard"></i>
              <p><?=\Yii::t('common', 'Homepage')?></p>
            </a>
          </li>
          <li class="dropdown" id="header-campaign">
            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
              <i class="fa fa-tasks"></i>
              <p>活动 <span class="caret"></span></p>
            </a>
            <ul class="dropdown-menu sub-nav" role="menu">
              <li class="" id="label-nav">
                <a href="<?php echo Url::to(['campaign-label/index']); ?>">
                  <p>
                    <i class="fa fa-globe"></i>
                    <?=\Yii::t('common', 'Campaign Label Management')?>
                  </p>
                </a>
              </li>
              <li class="" id="launch-nav">
                <a href="<?php echo Url::to(['launch/index']); ?>">
                  <p>
                    <i class="fa fa-rocket"></i>
                    <?=\Yii::t('common', 'Campaign Management')?>
                  </p>
                </a>
              </li>
              <li class="" id="strategy-nav">
                <a href="<?php echo Url::to(['strategy/index']); ?>">
                  <p>
                    <i class="fa fa-puzzle-piece"></i>
                    <?=\Yii::t('common', 'Solution Management')?>
                  </p>
                </a>
              </li>
              <li class="" id="creative-nav">
                <a href="<?php echo Url::to(['creative/index']); ?>">
                  <p>
                    <i class="fa fa-sun-o"></i>
                    <?=\Yii::t('common', 'Creative Management')?>
                  </p>
                </a>
              </li>
            </ul>
          </li>
          <li class="" id="header-resource">
            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
              <i class="fa fa-star"></i>
              <p>资源 <span class="caret"></span></p>
            </a>
            <ul class="dropdown-menu sub-nav" role="menu">
              <li class="" id="media-list-nav">
                <a href="<?php echo Url::to(['media-list/index']); ?>">
                  <p>
                    <i class="fa fa-sitemap"></i>
                    媒体列表
                  </p>
                </a>
              </li>
              <li class="" id="creative-template-nav">
                <a href="<?php echo Url::to(['creative-template/index']); ?>">
                  <p>
                    <i class="fa fa-cube"></i>
                    创意模板
                  </p>
                </a>
              </li>
              <!-- <li>
                <a href="<?php echo Url::to(['period-deal/index']); ?>">
                  <p>
                    <i class="fa fa-clock-o"></i>
                    优选媒体列表
                  </p>
                </a>
              </li> -->
            </ul>
          </li>
         
          <li class="" id="header-report">
            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
              <i class="fa fa-newspaper-o"></i>
              <p>数据报表 <span class="caret"></span></p>
            </a>
            <ul class="dropdown-menu sub-nav" role="menu">
				<li class="" id="label-report-nav">
                <a href="<?php echo Url::to(['report/index']); ?>">
                  <p>
                    <i class="fa fa-reorder"></i>
                    投放报表
                  </p>
                </a>
              </li>
			   <!-- <li class="" id="label-report-nav">
                <a href="<?php echo Url::to(['campaign-report/index']); ?>">
                  <p>
                    <i class="fa fa-reorder"></i>
                    投放报表
                  </p>
                </a>
              </li>
             <li class="" id="creative-report-nav">
                <a href="<?php echo Url::to(['creative-report/index']); ?>">
                  <p>
                    <i class="fa fa-photo"></i>
                    创意报表
                  </p>
                </a>
              </li>
              <li class="" id="adspace-report-nav">
                <a href="<?php echo Url::to(['adspace-report/index']); ?>">
                  <p>
                    <i class="fa fa-list-alt"></i>
                    广告位报表
                  </p>
                </a>
              </li> -->
            </ul>
          </li>
		  <!-- ------------------ 运营管理 beg ------------------ -->
		  <?php 
			$monitor = Url::to(['summary-report/index']);
			$summary = Url::to(['summary-report/index']);
			$profitSetting = Url::to(['profit-setting/index']);
			$advertiserManager = Url::to(['advertiser/index']);
      $materailManager = Url::to(['material/index']);
      $tanxManager = Url::to(['tanx-manage/list']);
			$userManager = Url::to(['users/index']);
			$log = Url::to(['operate-log/index']);
      $retarget = Url::to(['retarget/index']);

			$operaterMenu = <<<FINE
          <li class="" id="header-operation">
            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
              <i class="fa fa-sliders"></i>
              <p>运营管理 <span class="caret"></span></p>
            </a>			
            <ul class="dropdown-menu sub-nav" role="menu">
FINE;
			if (in_array($_SESSION['user_rank'], ['root', 'operator', 'agent', 'advertiser']))
        echo $operaterMenu;

				$opMenus = <<<FINE
             <!--  <li>
                <a href="$monitor">
                  <p>
                    <i class="fa fa-desktop"></i>
                    投放监控
                  </p>
                </a>
              </li>
              <li>
                <a href="$summary">
                  <p>
                    <i class="fa fa-retweet"></i>
                    汇总报表
                  </p>
                </a>
              </li> -->
              <li class="" id="profit-setting-nav">
                <a href="$profitSetting">
                  <p>
                    <i class="fa fa-money"></i>
                    利润率设置
                  </p>
                </a>
              </li>
FINE;
			if (in_array($_SESSION['user_rank'], ['root']))
				echo $opMenus;

      $adManagementMenu = <<<FINE
              <li class="" id="advertiser-nav">
                <a href="$advertiserManager">
                  <p>
                    <i class="fa fa-tags"></i>
                    品牌管理
                  </p>
                </a>
              </li> 
FINE;
      if (in_array($_SESSION['user_rank'], ['root', 'operator']))
        echo $adManagementMenu;


			$tanxManagementMenu = <<<FINE
              <li class="" id="tanx-nav">
                <a href="$tanxManager">
                  <p>
                    <i class="fa fa-magnet"></i>
                    Tanx客户管理
                  </p>
                </a>
              </li>
              <!-- <li>
                <a href="$materailManager">
                  <p>
                    <i class="fa fa-image"></i>
                    素材管理
                  </p>
                </a>
              </li> -->
FINE;
			if (in_array($_SESSION['user_rank'], ['root', 'operator', 'agent', 'advertiser']))
				echo $tanxManagementMenu;

			$userManagementMenu = <<<FINE
              <li class="" id="users-nav">
                <a href="$userManager">
                  <p>
                    <i class="fa fa-users"></i>
                    用户管理
                  </p>
                </a>
              </li>
FINE;
			if (in_array($_SESSION['user_rank'], ['root']))
				echo $userManagementMenu;

			$logMenu = <<<FINE
              <li class="" id="operate-log-nav">
                <a href="$log">
                  <p>
                    <i class="fa fa-hdd-o"></i>
                    操作日志
                  </p>
                </a>
              </li>
              <li class="" id="operate-retarget-nav">
                <a href="$retarget">
                  <p>
                    <i class="fa fa-crosshairs"></i>
                    重定向管理
                  </p>
                </a>
              </li>
FINE;
			if (in_array($_SESSION['user_rank'], ['root', 'operator', 'agent', 'advertiser']))
				echo $logMenu;

			$logMenu = <<<FINE
            </ul>
          </li>
FINE;
			if (in_array($_SESSION['user_rank'], ['root', 'operator', 'agent', 'advertiser']))
				echo $logMenu;
		  ?>
		  <!-- ------------------ 运营管理 end ------------------ -->
		  <!-- ------------------ 同步管理 beg ------------------ -->
		  <?php 
			$resourceSync = Url::to(['resource-sync/index']);
			$creativeSync = Url::to(['creative-sync/index']);
			$launchRuleSync = Url::to(['package-sync/index']);
			$syncMenu = <<<FINE

			<li class="" id="header-sync">
            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
              <i class="fa fa-exchange"></i>
              <p>同步管理 <span class="caret"></span></p>
            </a>
            <ul class="dropdown-menu sub-nav" role="menu">
              <li class="" id="resource-sync-nav">
                <a href="$resourceSync">
                  <p>
                    <i class="fa fa-star-o"></i>
                    资源同步
                  </p>
                </a>
              </li>
              <li class="" id="creative-sync-nav">
                <a href="$creativeSync">
                  <p>
                    <i class="fa fa-paper-plane"></i>
                    创意同步
                  </p>
                </a>
              </li>
              <li class="" id="launch-rule-sync-nav">
                <a href="$launchRuleSync">
                  <p>
                    <i class="fa fa-plane"></i>
                    投放包同步
                  </p>
                </a>
              </li>
            </ul>
          </li>
FINE;
			if ($_SESSION['user_rank'] == 'root')
				echo $syncMenu;
		  ?>
		  <!-- ------------------ 同步管理 end ------------------ -->         
        </ul>
        <ul class="nav navbar-nav pull-right">
          <li>
            <a href="javascript:void(0);">
              <i class="fa fa-user"></i>
              <p><?= $_SESSION['user_name'] ?></p>
            </a>
          </li>
          <li>
            <a href="<?= Url::to(['home/user-update']);?>">
              <i class="fa fa-wrench"></i>
              <p>设置</p>
            </a>
          </li>
          <li>
            <a href="<?php echo Url::to(['index/logout']); ?>">
              <i class="fa fa-power-off"></i>
              <p>退出</p>
            </a>
          </li>
        </ul>
      </nav>
    </header>
    <div class="cont">
      <div class="loading-wrap" id="global-loading-wrap"></div>
      <div class="content">
        <div class="container-fluid">
          <div class="row">
            <div class="col-sm-6">
              <ol class="breadcrumb">
                <li>
                  首页
                </li>
                <li class="active">统计</li>
              </ol>
            </div>
            <div class="col-sm-6">
              <span class="advertiser-select pull-right">
                <div class="form-inline">
                  <div class="form-group">
                    <label>品牌选择：</label>
                    <select name="advertiserName" id="advertiser-name" class="form-control">
						<?php
							$currentAdvertiserId = '';
							if (isset($_SESSION['advertiser_id'])) {
								$currentAdvertiserId = $_SESSION['advertiser_id'];
							}
							if(count($_SESSION['domainAdvertisers']) ==0) {								
								echo "<option value='' >暂无品牌</option>";
							}
							foreach ($_SESSION['domainAdvertisers'] as $advertiser) {
								$id = $advertiser['id'];
								$name = $advertiser['name'];
								$isSelected = '';
								if ($id == $currentAdvertiserId) {
									$isSelected = "selected";
								}
								echo "<option value='$id' $isSelected>$name</option>";
							}
						?>
                    </select>
                  </div>
                </div>
              </span>
            </div>
          </div>
          <!-- </div> -->
          <?= $content ?>
        </div>
      </div>
    </div>
  </div>
  <footer class="footer">
    <div class="container">
      <p class="text-center">
        Copyright&copy; <?= date('Y') ?> ValueMaker All Rights Reserved. 万流客网络科技（上海）有限公司 版权所有 - 
        <?= Yii::powered() ?>
        &nbsp; Powered by 
        <a href="javascript:void(0);" rel="external">ValueMaker DSP</a>
      </p>
    </div>
  </footer>
<?php $this->endBody() ?>
<?= $this->render('_baiduAnalytics') ?>
</body>
</html>
<?php $this->endPage() ?>
